﻿/*
* ==============================================================================
*
* Filename: call_phoneaddress_util
* Description: call_phoneaddress_util
*
* Version: 1.0
* Created: 2020/9/3 15:28:16
* Compiler: Visual Studio 2019
*
* Author: Administrator
* Company: freelancer
*
* ==============================================================================
*/

namespace db_util {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.Threading.Tasks;
	using db_model;
	using MySql.Data.MySqlClient;

	public class call_phoneaddress_util {
		public static call_phoneaddress_model GetModel(string number) {
			var model = new call_phoneaddress_model();
			string sql = "select id,number,area_code,area,province,telecom from call_phoneaddress where number=?number limit 1";
			MySqlParameter[] parameters = {
	 new MySqlParameter("?number", MySqlDbType.VarChar,100)
				};
			parameters[0].Value = number;
			using (var dr = mysql_helper.GetDataReader(sql, parameters)) {
				if (dr.Read()) {
					model.id = int.Parse(dr["id"].ToString() == "" ? "-1" : dr["id"].ToString());
					model.number = dr["number"].ToString();
					model.area_code = dr["area_code"].ToString();
					model.area = dr["area"].ToString();
					model.province = dr["province"].ToString();
					model.telecom = dr["telecom"].ToString();
				}
			}
			return model;
		}

	}
}